<?php
/**
 * Created by PhpStorm.
 * User: Coderjianfeng
 * Date: 15/8/17
 * Time: 下午3:52
 */

class Model_User extends PhalApi_Model_NotORM {

    public function getByUserPhone($userphone, $password){
        $rs = array();
        $rs = DI()->notorm->User->select('*')->where('phone = ?',$userphone)->fetch();
        if(empty($rs)){
            return array('code' => 1);
        }
        return DI()->notorm->User->select('*')->where('phone = ? and password = ?', $userphone, $password)->fetch();
    }

    public function doRegister($userphone, $password){
        $id = $this->insert(array('phone' => $userphone, 'password' => $password));
        return $id;
    }

    public function updatePwd($id, $password){
        $rs = $this->update($id,array('password' => $password));
        return $rs;
    }

    protected  function  getTableName($id){
        return 'User';
    }
}